Skip to content

Add ISO/IEC 8211 writer/encoder and builders (#12)#13

Merged
philliphoff merged 1 commit into
mainfrom
philliphoff-iso8211-writer
Jul 12, 2026
Merged

Add ISO/IEC 8211 writer/encoder and builders (#12)#13
philliphoff merged 1 commit into
mainfrom
philliphoff-iso8211-writer

Conversation

@philliphoff

Copy link
Copy Markdown
Owner

Adds a first-class ISO/IEC 8211 writer/encoder — the symmetric inverse of the existing reader — so datasets can be produced, not just parsed. Closes #12.

What's new (8 source files under src/EncDotNet.Iso8211, no breaking changes to reader APIs)

  • Iso8211DocumentWriterWrite(doc) → byte[], Write(Stream) / WriteAsync, WriteToFile / WriteToFileAsync. Round-trippable and byte-identical for canonically-encoded sources (recomputes only directory / base address / record length).
  • Iso8211RecordWriter — encodes one record (leader + directory + field area).
  • Iso8211SubfieldEncoder — inverse of the reader's ConvertValue; handles every Iso8211SubfieldFormatType (fixed/variable char, ASCII int/real, signed/unsigned/floating binary little-endian at declared widths, bit strings).
  • Iso8211FieldBuilder / Iso8211RecordBuilder / Iso8211DocumentBuilder — fluent construction from scratch, mirroring reader subfield sequencing, repeating-group wrap, and UT/FT placement.
  • Iso8211DataDescriptiveRecordWriter — DDR encoder (field controls + descriptors + format controls, canonical 2-UT layout).
  • Iso8211WriterOptions — lexical level, encoding (ASCII default), directory entry auto-sizing.

Tests

Byte-identical round-trips, builder Write→Read model equivalence, per-format encode/decode, DDR encode→read, stream/file overloads, plus an opt-in corpus round-trip that self-skips unless ISO8211_CORPUS_DIR is set. Full suite: 469 passed, 0 failed. Builds clean for net8.0;net10.0. XML docs on all new public types; README updated with a writing/builders section.

Motivation

Unblocks downstream philliphoff/EncDotNet.S100, which needs to serialize an S101Document back to a .000 cell for an s100 s57 convert command.

Implement a first-class writer/encoder for EncDotNet.Iso8211 as the
symmetric inverse of the existing reader, enabling downstream
serialization of documents back to .000 cells.

Round-trip surface:
- Iso8211DocumentWriter: Write(doc)->byte[], Write(Stream), WriteAsync,
  WriteToFile/WriteToFileAsync. Byte-identical for canonical sources.
- Iso8211RecordWriter: encodes one record (leader/directory/field area).
- Iso8211WriterOptions: lexical level, encoding, entry-map auto-sizing.

Construction-from-scratch:
- Iso8211SubfieldEncoder: encodes every Iso8211SubfieldFormatType
  (inverse of the reader's ConvertValue).
- Iso8211FieldBuilder / Iso8211RecordBuilder / Iso8211DocumentBuilder:
  fluent builders mirroring reader subfield sequencing and UT placement.
- Iso8211DataDescriptiveRecordWriter: encodes DDR field definitions.

Tests: byte-identical round-trips, builder Write->Read, per-format
encode/decode, DDR encode->read, stream/file overloads, and an
opt-in corpus round-trip (skips without ISO8211_CORPUS_DIR).

No breaking changes to reader APIs; XML docs on all new public types.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ead2ac19-7b31-431f-84c2-edb303f789fe
@philliphoff philliphoff merged commit f00eb65 into main Jul 12, 2026
6 checks passed
@philliphoff philliphoff deleted the philliphoff-iso8211-writer branch July 12, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ISO 8211 writer/encoder (symmetric inverse of the reader)

1 participant